package com.fy.admin.controller;


import com.fy.admin.feign.ScenicManagementFeignService;
import com.fy.admin.vo.ScenicVo;
import com.fy.common.api.CommonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/scenic")
@Api(tags="景区管理")
@RefreshScope
public class ScenicManagementController {
    @Autowired
    ScenicManagementFeignService service;
    @ApiOperation("查询所有")
    @GetMapping(value = "/findAll/{pageSize}/{limit}")
    public CommonResult findAll(@PathVariable Integer pageSize, @PathVariable Integer limit)
    {
        return CommonResult.success(service.findAll(pageSize,limit));
    }

    @ApiOperation("添加景区")
    @PostMapping(value = "/add")
    public CommonResult add(@RequestBody ScenicVo scenicVo)
    {
        return service.add(scenicVo);
    }
    @ApiOperation("编辑景区")
    @PostMapping(value = "/edit")
    public CommonResult edit(@RequestBody ScenicVo scenicVo)
    {
        return service.edit(scenicVo);
    }
    @ApiOperation("删除景区")
    @DeleteMapping(value = "/delete/{id}")
    public CommonResult delete(@PathVariable Integer id)
    {
        return service.delete(id);
    }
    @ApiOperation("根据景区ID查询")
    @GetMapping(value = "/findById/{id}")
    public CommonResult findById(@PathVariable Integer id)
    {
        return service.findById(id);
    }
}
